import { series, parallel, watch } from 'gulp'
import Config from './config'
import Clean from './tasks/clean'
import Server from './tasks/server'
import Html from './tasks/html'
import Script from './tasks/script'
import Style from './tasks/style'
import Static from './tasks/static'
import Image from './tasks/image'

function watchTask() {
  watch(Config.html.watch, Html.build)
  watch(Config.script.watch, series(Script.eslint, Script.build))
  watch(Config.style.watch, Style.build)
  watch(Config.static.watch, Static.copy)
  watch(Config.image.watch, Image.build)
}

const build = series(Clean.delete, Static.copy, Image.build, Style.build, Script.eslint, Script.build, Html.build)
const dev = series(build, parallel(watchTask, Server.run))

class Build {
  static build = build
  static dev = dev
}

export default Build